package www.openteam.com.presenter.business.other;


import java.util.HashMap;

import www.openteam.com.base.BasePresenter;
import www.openteam.com.bean.PeopleGroup;
import www.openteam.com.contract.business.other.WOSearchContract;
import www.openteam.com.model.business.other.WOSearchModel;
import www.openteam.com.mvp.IModel;
import www.openteam.com.ui.business.other.WOSearchFragment;

/**
 * Created by kylin on 2017/5/3.
 */

public class WOSearchPresenter extends BasePresenter<WOSearchFragment> implements
        WOSearchContract.WOSearchPresenter{
    @Override
    public void findPeopleGroup( String code,int pageSize) {
        ((WOSearchModel)getiModelMap().get("wSearch")).findPeopleGroup(
                code,pageSize, new WOSearchModel.WOSearchOnListener() {
                    @Override
                    public void suceessSInfo(PeopleGroup peopleGroup) {
                        getIView().querySSuccess(peopleGroup);
                    }

                    @Override
                    public void failSInfo(String error) {

                        getIView().querySFail(error);
                    }
                });
    }

    @Override
    public void findBanzu(String code, int pageSize) {
        ((WOSearchModel)getiModelMap().get("wSearch")).findBanzu(code, pageSize,
                new WOSearchModel.WOSearchBOnListener() {
            @Override
            public void suceessBInfo(PeopleGroup banGroup) {

                getIView().queryBSuccess(banGroup);
            }

            @Override
            public void failBInfo(String error) {
                getIView().queryBFail(error);
            }
        });
    }


    @Override
    public HashMap<String, IModel> getiModelMap() {

        return loadModelMap(new WOSearchModel());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {
        HashMap<String,IModel>  hashMap =new HashMap<>();
        hashMap.put("wSearch",models[0]);
        return hashMap;
    }
}
